package com.example.myblog.pojo;

import java.util.List;
import java.util.Objects;

/**
 * @BelongsProject: MyBlog
 * @BelongsPackage: com.example.myblog.pojo
 * @ClassName User
 * @CreateTime: 2025-05-28  22:56
 * @Author: TangLiFei
 */
public class User {
    private Integer id;
    private String account;
    private String pwd;
    private List<String> authorities; // 存储用户的权限（如 ROLE_admin、ROLE_common）

    public Integer getId() { return id; }
    public void setId(Integer id) { this.id = id; }
    public String getAccount() { return account; }
    public void setAccount(String account) { this.account = account; }
    public String getPwd() { return pwd; }
    public void setPwd(String pwd) { this.pwd = pwd; }
    public List<String> getAuthorities() { return authorities; }
    public void setAuthorities(List<String> authorities) { this.authorities = authorities; }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        User user = (User) o;
        // 基于用户唯一标识（id/account/pwd）判断是否为同一用户
        return Objects.equals(id, user.id) &&
                Objects.equals(account, user.account) &&
                Objects.equals(pwd, user.pwd);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, account, pwd);
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", account='" + account + '\'' +
                ", pwd='" + pwd + '\'' +
                ", authorities=" + authorities +
                '}';
    }
}
